﻿using System;

namespace WPNextTools.NBase
{
    public struct BitVector32
    {
        private uint data;
        public uint Data
        {
            get
            {
                return this.data;
            }
        }
        public bool this[uint key]
        {
            get
            {
                return (this.data & key) == key;
            }
            set
            {
                if (value)
                {
                    this.data |= key;
                    return;
                }
                this.data &= ~key;
            }
        }
        public BitVector32(BitVector32 source)
        {
            this.data = source.data;
        }
        public BitVector32(uint data)
        {
            this.data = data;
        }
        public static bool operator ==(BitVector32 vector1, BitVector32 vector2)
        {
            return vector1.data == vector2.data;
        }
        public static bool operator !=(BitVector32 vector1, BitVector32 vector2)
        {
            return vector1.data != vector2.data;
        }
        public void Reset()
        {
            this.data = 0u;
        }
        public override bool Equals(object obj)
        {
            return obj is BitVector32 && (BitVector32)obj == this;
        }
        public override int GetHashCode()
        {
            return this.data.GetHashCode();
        }
    }
}
